<template>
  <el-dialog title="人员管理详情" :visible.sync="visible" width="900px" append-to-body v-if="visible" :before-close="onClose" close-on-click-modal>
    <el-row>
      <el-col :span="24">
        <el-select
          v-model="queryParams.subType"
          placeholder="人员类型"
          clearable
          size="mini"
          style="margin-bottom: 10px;"
        >
          <el-option
            v-for="dict in dict.type.drug_user_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
        <el-button type="primary" size="mini" @click="getList" style="margin-left: 10px;">查询</el-button>
        <el-button size="mini" @click="reset" style="margin-left: 10px;">重置</el-button>
      </el-col>
      <el-col :span="24">
        <el-table v-loading="loading" :data="data">
          <el-table-column label="姓名" align="center" prop="name" />
          <el-table-column label="身份证" align="center" prop="idno" />
          <el-table-column label="联系电话" align="center" prop="mobile" />
          <el-table-column label="最新家访时间" align="center" prop="jfrq" />
          <el-table-column label="人员类型" align="center" prop="subType" >
            <template slot-scope="scope">
              <dict-tag :options="dict.type.drug_user_type" :value="scope.row.subType"/>
            </template>
          </el-table-column>
        </el-table>
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>
  </el-dialog>
</template>

<script>

import {listUser} from "@/api/user/userInfo";

export default {
  name: "mgrUserList",
  dicts: ['drug_user_type'],
  data() {
    return {
      data: [],
      total: 0,
      visible: false,
      loading: false,
      queryParams: {
        renderJfrq: true,
        pageNum: 1,
        pageSize: 10,
        fzr: undefined,
        subType: undefined,
      },
    }
  },
  methods: {
    reset() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        fzr: this.queryParams.memberId,
        type: undefined,
      }
      this.getList()
    },
    onClose() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        fzr: undefined,
        type: undefined,
      }
      this.visible = false
    },
    open(memberId) {
      this.visible = true
      this.queryParams.fzr = memberId
      this.getList()
    },
    getList() {
      this.data = []
      this.total = 0
      this.loading = true;
      listUser(this.queryParams).then(response => {
        this.data = response.rows;
        this.total = response.total;
      }).finally(() => {
        this.loading = false;
      });
    }
  }
}
</script>

<style scoped>

</style>
